package com.wochoose.jojo.ucm.biz.mybatis.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wochoose.jojo.ucm.biz.mybatis.domain.UserLike;
import com.wochoose.jojo.ucm.biz.mybatis.domain.UserLikeDetail;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserLikeDetailMapper extends BaseMapper<UserLike> {
    @Select({
        "select id, liked_user_id, liked_post_id, status, rcd_crt_time, rcd_mod_time",
        "from user_like",
        "where liked_post_id = #{likedPostId,jdbcType=BIGINT} and status=#{status,jdbcType=INTEGER}"
    })
    List<UserLikeDetail> findByLikedUserIdAndStatus(@Param("likedUserId") Long likedUserId, @Param("status") Byte status);

    @Select({
        "select id, liked_user_id, liked_post_id, status, rcd_crt_time, rcd_mod_time",
        "from user_like",
        "where liked_user_id = #{likedUserId,jdbcType=BIGINT} and liked_post_id = #{likedPostId,jdbcType=BIGINT}"
    })
    List<UserLikeDetail> findByLikedPostIdAndStatus(@Param("likedPostId") Long likedPostId, @Param("status") Byte status);

    /**
     * 根据点赞用户及被点赞用户查找记录
     *
     * @param likedUserId
     * @param likedPostId
     * @return
     */
    @Select({
        "select id, liked_user_id, liked_post_id, status, rcd_crt_time, rcd_mod_time",
        "from user_like",
        "where liked_user_id = #{likedUserId,jdbcType=BIGINT} and status=#{status,jdbcType=INTEGER}"
    })
    UserLikeDetail findByLikedUserIdAndLikedPostId(@Param("likedUserId") Long likedUserId, @Param("likedPostId") Long likedPostId);
}
